#include<iostream>
#include<unistd.h>
#include<cstdio>
using namespace std;

int global_val = 100;

int main(){
  pid_t id = fork();
  if(id < 0)  perror("fork faild");
  else if(id == 0){
    int cnt = 0;
    while(1){
      cout<<"pid:"<<getpid()<<"ppid:"<<getppid()<<"global_val="<<global_val<<" "<<&global_val<<endl;
      cnt++;
      if(cnt == 10) {cout<<"cnt is change......."<<endl;
        global_val = 300;
      }
      sleep(1);
    }
  }else{
    while(1){
      cout<<"pid:"<<getpid()<<"ppid:"<<getppid()<<"global_val="<<global_val<<" "<<&global_val<<endl;
      sleep(2);
    }
    
  }
  return 0;
}
